package com.da.javatest.leetCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chenlida
 * @date 2018/12/18 15:53
 * @description
 */
public class Code589 {
    public static void main(String[] args) {
        new Code589().preorder(new Node(1, null));
    }

    private List<Integer> result = new ArrayList<>();

    public List<Integer> preorder(Node root) {
        if (root == null) { return result; }
        result.add(root.val);
        if (root.children != null) {
            for (Node child : root.children) {
                preorder(child);
            }
        }
        return result;
    }
}
